﻿@model DA.Department
@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<h2>
    Edit</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Department</legend>
        @if (Model != null && Model.DeptId != 0)
        {
            @Html.HiddenFor(model => model.DeptId)
        }
        <div class="editor-label">
            @Html.LabelFor(model => model.DeptName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DeptName)
            @Html.ValidationMessageFor(model => model.DeptName)
        </div>
        @if ((bool)ViewBag.IsClientAdmin)
        {
            <div class="editor-label">
                @Html.LabelFor(model => model.ClientId, "Client")
            </div>
            <div class="editor-field">
            @if (Model != null)
            {
                @Html.DisplayFor(model => model.Client.Name)
            }
            else
            {
                @Html.DropDownList("ClientId", (IEnumerable<SelectListItem>)ViewBag.ClientId)
                @Html.ValidationMessageFor(model => model.ClientId)
            }
            </div>
        }
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
